/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package carrancao.util;

import carrancao.entidades.Cliente;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Lubnnia
 */
public class ClienteTableModel extends AbstractTableModel {

    private List<Cliente> clientes;

    public ClienteTableModel(List<Cliente> clientes) {
        this.clientes = clientes;
    }

    public int getRowCount() {
        return clientes.size();
    }

    public int getColumnCount() {
        return 4;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Cliente c = getCliente(rowIndex);

        if(c != null) {
            switch(columnIndex) {
                case 0:
                    return c.getNome();
                case 1:
                    return c.getEmail();
                case 2:
                    return c.getCelular();
                case 3:
                    return c.getObs();
            }
        }
        return  null;
    }

    public String getColumnName(int column){
        switch (column) {
            case 0:
		return "Cliente";
            case 1:
            	return "Email";
            case 2:
		return "Telefone";
            case 3:
		return "Obs Gerais";
        }
	return null;
    }

    public Class<?> getColumnClass(int column){
        switch (column) {
            case 0:
		return String.class;
            case 1:
		return String.class;
            case 2:
            	return String.class;
            case 3:
		return String.class;
        }
	return null;
    }

    public Cliente getCliente(int row) {
        if(row >= 0) {
            return clientes.get(row);
        }
        return null;
    }

}
